// tagBox.js
Component({
  properties: {
    list: {
      type: Array,
      value: [],
      observer(val) {
        this.add2Dic(val)
      }
    }
  },

  data: {
    dic: {}
  },

  methods: {
    handleAddOrRemoveTag(e) {
      let dic = this.data.dic
      dic[e.currentTarget.dataset.name] = !dic[e.currentTarget.dataset.name]
      this.setData({
        dic
      })
      this.triggerEvent('change', {
        tags: dic
      })
    },

    add2Dic(val) {
      let o = {}
      for (let i = 0; i < val.length; i++) {
        o[val[i]] = true
      }
      this.setData({
        dic: o
      })
    },
  },



})